using Assets.Scripts.GDK;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class ShopGiftItem : gdk_base_layer
	{
		public RectTransform addIcon02;

		public RectTransform btn;

		public Text MoneyText;

		public Image[] rawdIcons;

		public Text[] rardCounts;

		private GameGiftModel myGiftInfo;

		public void OnData(GameGiftModel gameShopModel, Action callback)
		{
			myGiftInfo = gameShopModel;
			MoneyText.text = "$" + gameShopModel.dollar;
			float num = gdk_stringPlus.string2float(gameShopModel.addScale);
			bool flag = num > 0f;
			addIcon02.gameObject.SetActive(flag);
			if (flag)
			{
				Text component = gdk_utils.FindChild(addIcon02, "Text").GetComponent<Text>();
				component.text = "+" + (num * 100f).ToString() + "%";
			}
			btn.GetComponent<Button>().onClick.AddListener(delegate
			{
				gdk_game_manager.PlaySound(AudioID.click);
				callback();
			});
			setReward(gameShopModel.rawdCount);
			setRewardIcon(gameShopModel.rawdType);
		}

		private void setReward(int[] counts)
		{
			for (int i = 0; i < counts.Length; i++)
			{
				rardCounts[i].text = "x" + counts[i].ToString();
			}
		}

		private void setRewardIcon(int[] types)
		{
			for (int i = 0; i < types.Length; i++)
			{
				setIcon(rawdIcons[i], types[i], myGiftInfo.rawdCount[i]);
			}
		}

		private void setIcon(Image img, int rewardType, int rewardCount)
		{
			switch (rewardType)
			{
				case 2:
					switch (rewardCount)
					{
						case 3000:
							img.sprite = gdk_game_manager.loadSprite("UI/Shop/store_j_zs7");
							break;
						case 5000:
							img.sprite = gdk_game_manager.loadSprite("UI/Shop/store_j_zs8");
							break;
						case 10000:
							img.sprite = gdk_game_manager.loadSprite("UI/Shop/store_j_zs9");
							break;
						default:
							img.sprite = gdk_game_manager.loadSprite("UI/Shop/common_zs");
							break;
					}
					break;
				case 3:
					img.sprite = gdk_game_manager.loadSprite("UI/Game/dj_2");
					break;
				case 4:
					img.sprite = gdk_game_manager.loadSprite("UI/Game/dj_1");
					break;
				case 5:
					img.sprite = gdk_game_manager.loadSprite("UI/Game/dj_5");
					break;
				case 6:
					img.sprite = gdk_game_manager.loadSprite("UI/Game/dj_3");
					break;
				case 7:
					img.sprite = gdk_game_manager.loadSprite("UI/Game/dj_4");
					break;
			}
			img.SetNativeSize();
		}
	}
}

